﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VgoCardChange.Models.Objects;
using VgoCardChange.Models;

namespace VgoCardChange.Controllers
{
    public class GuildController : Controller
    {
        //
        // GET: /Guild/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult GetGuilds()
        {
            List<Guild> listguild = new List<Guild>();
            GuildModels GuildMd = new GuildModels();
            listguild = GuildMd.GetGuild();
            ViewData["listguild"] = listguild;
            return View();
        }
        public ActionResult CreateGuild()
        {
            return View();
        }
        [HttpPost]
        public ActionResult CreateGuild(string GuildName, int Player_Number)
        {
            GuildModels GuildMd=new GuildModels();
            Guild guild=new Guild();
            guild.GuildName=GuildName;
            guild.Player_Number=Player_Number;
            GuildMd.CreateGuild(guild);
            return RedirectToAction("GetGuilds");
        }
        public ActionResult EditGuild(int GuildID)
        {
            GuildModels GuildMd = new GuildModels();
            List<Guild> listguildid = new List<Guild>();
            listguildid = GuildMd.GetGuildID(GuildID);
            ViewData["listguildid"] = listguildid;
            return View();
        }
        [HttpPost]
        public ActionResult EditGuild(int GuildID, string GuildName, int Player_Number)
        {
            GuildModels GuildMd = new GuildModels();
            Guild guild = new Guild();
            guild.GuildID = GuildID;
            guild.GuildName = GuildName;
            guild.Player_Number = Player_Number;
            GuildMd.EditGuild(guild);
            return RedirectToAction("GetGuilds");
 
        }
        public ActionResult DeleteGuild(int GuildID)
        {
            GuildModels GuildMd = new GuildModels();
            List<Guild> listguildid = new List<Guild>();
            listguildid = GuildMd.GetGuildID(GuildID);
            ViewData["listguildid"] = listguildid;
            return View();
        }
        [HttpPost]
        public ActionResult DeleteGuild(int GuildID, FormCollection coll)
        {
            GuildModels GuildMd = new GuildModels();
            GuildMd.DeleteGuild(GuildID);
            return RedirectToAction("GetGuilds");
        }

    }
}
